package com.zgw.his.design.model;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.spi.SyncProviderException;

import com.sun.rowset.CachedRowSetImpl;

public class Dataset {
	CachedRowSet set;
	private String name;
	List<DatasetItem> children;
	private String command;

	public Dataset() {
		children = new ArrayList<DatasetItem>();
		try {
			set = new CachedRowSetImpl();
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}

	public void setCommand(String command) {
		this.command = command;

		command = "insert into ";
		try {
			set.acceptChanges();
			set.getMetaData();
			set.setString(0, "");
			Connection connection = null;
			set.setCommand(this.command);
			set.execute(connection);
			set.getMetaData();
			String sql = "insert into(fkh,fname) zy.tzybr values(?,?)";

		} catch (SyncProviderException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	protected void crateitem(DatasetItem item) {
		if (!children.contains(item))
			children.add(item);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
